package model.timers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;

import model.Player;

import commands.CallCommand;
import commands.Command;
import commands.FoldCommand;
import commands.RaiseCommand;
import controller.CommandManager;

public class HandTimer implements ActionListener {

	
	private Timer timer;
	private Player player;
	/**
	 * Specify the amount of time for a turn in seconds
	 * @param turnTime
	 */
	public HandTimer(int turnTime, Player player){
		this.timer = new Timer(turnTime * 100, this);
		this.player = player;
	}
	
	public void start(){
		this.timer.restart();
	}
	
	public void stop(){
		this.timer.stop();
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		//create fold command
		System.out.println("Player" + player.getSeat() + " timed out. Folding them.");
		Command c = new FoldCommand(player.getSeat());
				
		//give it to the command manager
		CommandManager.performActionCommand(c);
	}
}
